<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>props函数组件使用</title>
  <!-- react核心库 -->
  <script src="../js/react.development.js"></script>
  <!-- react扩展库支持react操作DOM -->
  <script src="../js/react-dom.development.js"></script>
  <!-- 1.ES6转ES5；2.jsx转js -->
  <script src="../js/babel.min.js"></script>
  <!-- prop操作 -->
  <script src="../js/prop-types.js"></script>
</head>

<body>
  <div id="test"></div>
  <script type="text/babel">
    function Person(props) {
      console.log(props)
      const {name,age,sex} = props
      return(
        <ul>
          <li>姓名：{name}</li>
          <li>性别：{age}</li>
          <li>年龄：{sex}</li>
        </ul>
      )
    }
    Person.propTypes={
      name: PropTypes.string.isRequired,
      age: PropTypes.number
    }
    Person.defaultProps = {
      age: 20,
      sex: '男'
    }
    ReactDOM.render(<Person name='张三' />, document.getElementById('test'))
  </script>
</body>

</html>